function out_int = f_confid_I(n,p,alpha)
% n: number of trials overall
% p: Percentage
% alpha: significnat level, such as 0.05;

xs = 0:0.01:5;
for i = 1:length(xs);
    x = xs(i);
    fnorm(i) = 1/sqrt(2*pi).*exp(-x.*x./2);
    if i==1
        sum_all(i) = fnorm(i);
    else
        sum_all(i) =sum_all(i-1)+ fnorm(i);
    end
end
% plot(xs,fnorm)
% plot(sum_all)
Ind = find(sum_all>sum_all(end).*(1-alpha));
z = xs(Ind(1));
out_int = z.*sqrt(p*(1-p)./n);
return
